/*
 * 该controller放置所有不需要走登录校验的接口
 *
 */
module.exports = {

  /**
   * 跳转到登录页
   * @param req
   * @param res
   */
  gotoLogin(req,res){
    if(req.session.user){
      return res.redirect("/index");
    }
    res.view('pages/login/loginPage', {
      title: '登录',
    })
  },

  doLoginOut(req,res){
    let openid  = req.session.wechat.openid;
    let phone  = req.session.user.phone;
    ServerApiService.toLogOut(req, {phone:phone,openid:openid})
      .then(result => {
        if(200 == result.code){
          SessionUtil.clearLoginSession(req,false);
          SessionUtil.setSessionValue(req,"enterUrl","");
        }
        res.send(result)
      })
      .catch(err => {
        sails.log.error(err)
      })
  },
}
